﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApprovalProcess.aspx.cs" Inherits="CentralOffice.WebClient.Admin.Flow.ApprovalProcess" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../theme/2/style.css" />
    <script type="text/javascript" src="../../inc/js/jquery/jquery-1.3.2-vsdoc.js"></script>
</head>
<body class="bodycolor" topmargin="5">
<div style="margin-top:10px;"><img src="../../images/sys_config.gif" WIDTH="22" HEIGHT="20" align="absmiddle" /><span class="big3">流程管理</span></div>
    <form id="form1" runat="server"><ajaxToolkit:ToolkitScriptManager runat="server" ID="sm"  />

<div style="text-align:center">
<asp:UpdatePanel UpdateMode="Conditional" ID="upProcess" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<huag:OAGridView  id="gv" runat="server" DataKeyNames="Id" AllowSorting="True" skinid="GridView" EnableExport="false" Width="100%" ConfirmDelete="true"  DataSourceID="odsApprovalProcess" OnSelectedIndexChanged="gv_SelectedIndexChanged" EnableViewState="false" >
   <Columns>
       <huag:EnumTypeField DataField="ApprovalObject" HeaderText="审批种类" SortExpression="ApprovalObject" CategoryName="approvalObject"  />
       <asp:HyperLinkField DataTextField="Name" DataNavigateUrlFormatString="ApprovalProcessUpdate.aspx?id={0}" DataNavigateUrlFields="Id" HeaderText="审批名称" SortExpression="Name"/>
       
       <asp:CommandField HeaderText="查看此类审批的审批步骤"  ShowSelectButton="True" SelectText="选择" />
       <asp:CommandField ShowDeleteButton="true"  DeleteText="删除" />
   </Columns>
</huag:OAGridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>

<asp:ObjectDataSource id="odsApprovalProcess" runat="server"  
 TypeName="CentralOffice.Admin.BusinessActions.ApprovalProcess" 
 SelectMethod="GetAll" 
 DeleteMethod="DeleteById" ondeleting="odsApprovalProcess_Deleting" 
        ondeleted="odsApprovalProcess_Deleted">
</asp:ObjectDataSource>

<div style="margin-top:20px; margin-left:8px;"><h3>选定流程的审批步骤：</h3></div>
<div style="text-align:center">

<asp:UpdatePanel UpdateMode="Conditional" ID="upStep" runat="server" ChildrenAsTriggers="false">
<ContentTemplate>
<huag:OAGridView  id="gvStep" runat="server" DataKeyNames="Id" AllowSorting="True"  EnableExport="false" ConfirmDelete="true"
        skinid="DefaultGridView" Width="100%"  EnableViewState="false" 
        onrowdeleted="gvStep_RowDeleted" onrowdeleting="gvStep_RowDeleting" >
   <Columns>
       <%--<asp:BoundField DataField="Name" HeaderText="名称" SortExpression="Name"  />--%>
       <asp:BoundField DataField="StepOrder" HeaderText="步骤序号" SortExpression="StepOrder" />
       <asp:HyperLinkField DataTextField="Name" DataNavigateUrlFormatString="ApprovalStepUpdate.aspx?id={0}" DataNavigateUrlFields="Id" HeaderText="步骤名称" SortExpression="Name"/>
       <asp:BoundField DataField="ApprovalProcess" HeaderText="所属审批流程" SortExpression="ApprovalProcess" />
      <%-- <asp:BoundField DataField="PreviousStep" HeaderText="上一步" SortExpression="PreviousStep" />--%>
       
       <asp:BoundField DataField="ApprovalByEmp" HeaderText="审批者" SortExpression="ApprovalByEmp" />
       <asp:BoundField DataField="ApprovalBy" HeaderText="审批角色" SortExpression="ApprovalBy" />
       <asp:BoundField DataField="ApprovalContent" HeaderText="要审批的内容" SortExpression="ApprovalContent" />
       <asp:CommandField ShowDeleteButton="true"  DeleteText="删除" />
   </Columns>
</huag:OAGridView>
</ContentTemplate>
</asp:UpdatePanel>

</div>
<div style="margin-left:20px; margin-top:10px;">
<input type="button" name="btnAddStep" id="btnAddStep" class="BigButton" style="display:none;" value="添加审批步骤" />
</div>
    </form>
    
<script type="text/javascript" language="javascript">
//<![CDATA[
//Sys.Application.add_load(applicationLoadHandler);
//Sys.Application.remove_load(applicationLoadHandler);

Sys.Application.add_init(applicationLoadHandler);
function applicationLoadHandler()
{
    if (parent.menu_top && parent.menu_top.window.document.getElementById('FlowManage')) {
        parent.menu_top.window.document.getElementById('FlowManage').className = 'active';
        parent.menu_top.window.document.getElementById('FlowEdit').className = '';
        parent.menu_top.window.document.getElementById('ApprovalStep').className = '';
    }
}

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoading(pageLoadingHandler);
var processId = "";

function pageLoadingHandler(sender, args) {
    var dataItems = args.get_dataItems();
    var btnAddStep = $get('btnAddStep');
    var temp = dataItems['upStep'];
    if (temp != null && temp.length > 30) {
        processId = temp;
    }
    
    if (btnAddStep !== null) {
        btnAddStep.style.display = "block";
        btnAddStep.onclick = function() {
        window.location = "ApprovalStepAdd.aspx?processid=" + processId;
            if (parent.menu_top && parent.menu_top.window.document.getElementById('FlowManage')) {
                parent.menu_top.window.document.getElementById('FlowManage').className = '';
                parent.menu_top.window.document.getElementById('FlowEdit').className = '';
                parent.menu_top.window.document.getElementById('ApprovalStep').className = 'active';
            }
        }
    }
    var responseText = dataItems['upProcess'];
    if (responseText === "1") {
        alert("此审批流程有审批步骤了，请先删除审批步骤！");
    }

    var responseText = dataItems['gvStep'];
    if (responseText === "s") {
        alert("此审批步骤已经使用了");
    }
}
//]]>
</script>

</body>
</html>
